home *** CD-ROM | disk | FTP | other *** search
- // ArrayHeap.h
-
- #ifndef ArrayHeap_h
- #define ArrayHeap_h
-
- #ifndef ArrayOf_h
- #include "ArrayOf.h"
- #endif
-
- template < class Element >
- class ArrayHeap
- {
- public:
- typedef int32 (*Comparison)( const Element&, const Element& );
-
- private:
- Element *heap;
- uint32 lastElement;
- const Comparison compare;
-
- void Sink( uint32 index );
- void MakeHeap();
-
- public:
- ArrayHeap( ArrayOf<Element>, Comparison );
-
- const Element& Top() const { Assert( lastElement > 0 ); return heap[1]; }
- void Pop();
-
- void Sort();
- };
-
- #ifndef ArrayHeap_cp
- #include "ArrayHeap.cp"
- #endif
-
- #endif
-